﻿using System;
using System.Linq;
using Autodesk.Revit.DB;

namespace YJKRevitDimensionText.OneKeyPlanDim.DimesionDataEx
{
	public class GridInfoCache
	{
		public Grid ThisGrid
		{
			get
			{
				return this.m_grid;
			}
		}

		public Line ThisGridLine
		{
			get
			{
				return this.m_lineGrid;
			}
		}

		public bool IsStartBubbleVisible
		{
			get
			{
				return this.m_bStartBubbleVisible;
			}
		}

		public bool IsEndBubbleVisible
		{
			get
			{
				return this.m_bEndBubbleVisible;
			}
		}

		public GridInfoCache(Grid grid, Autodesk.Revit.DB.Document doc, Transform trans = null)
		{
			this.m_grid = grid;
            this.m_bStartBubbleVisible = grid.IsBubbleVisibleInView((DatumEnds)0, doc.ActiveView);
            this.m_bEndBubbleVisible = grid.IsBubbleVisibleInView((DatumEnds)1, doc.ActiveView);
			Line line = grid.GetCurvesInView(0, doc.ActiveView).FirstOrDefault<Curve>() as Line;
			if (trans != null)
			{
				this.m_lineGrid = (line.CreateTransformed(trans) as Line);
				return;
			}
			this.m_lineGrid = line;
		}

		private Grid m_grid;

		private Line m_lineGrid;

		private bool m_bStartBubbleVisible;

		private bool m_bEndBubbleVisible;
	}
}
